package com.github.code

import android.graphics.Color
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.github.base.RegisterPresenter
import com.github.utils.PermissionUtils
import com.github.wui.RulerView.RulerView
import com.github.wui.TimerSelector.TimerSelector
import com.github.wui.WaterLampView.WaterLampView
import com.github.wui.XBottomNavigation.XBottomNavigation
import com.github.wui.chart.LineChartView
import com.github.wui.chart.chartDataSet.LineChartDataSet
import com.github.wui.circle.CircleConstraintLayout
import com.github.wui.circle.CircleLinearLayout
import android.Manifest;
import android.os.Build
import android.widget.Button
import androidx.annotation.RequiresApi
import com.github.utils.ToastUtil

@RegisterPresenter([MainPresenter::class])
class MainActivity : AppCompatActivity() {

    val bottomNavigationData = mutableListOf<Triple<String, Int, Int>>(
        Triple("搜索", R.mipmap.test1, R.mipmap.test1),
        Triple("我的", R.mipmap.test1, R.mipmap.test1),
    )

    @RequiresApi(Build.VERSION_CODES.R)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        PermissionUtils.init(this)

        findViewById<Button>(R.id.timer).setOnClickListener {

            PermissionUtils.getInstance()
                .requestPermissions(arrayOf<String>(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA),object :
                    PermissionUtils.IPermissionCallBack {
                    override fun granded() {
                        Log.e("TAG", "granded: 1111")
                    }

                    override fun error() {
                        Log.e("TAG", "granded: error")
                    }

                    override fun grandedWithPermission(grandedPermissionName: String?) {
                        Log.e("TAG", "grandedWithPermission: " + grandedPermissionName )
                    }

                    override fun errorWithPermission(grandedPermissionName: String?) {
                        Log.e("TAG", "errorWithPermission: " + grandedPermissionName )
                    }

                    override fun requestAfter() {
                        ToastUtil.toast(this@MainActivity,"开始请求权限")
                    }

                })
        }
    }

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String?>,
        grantResults: IntArray,
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    }
}